<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/9/6
  Time: 13:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <style type="text/css">
        .layui-tab-item{height: 900px;}
    </style>
    <script src="${pageContext.request.contextPath}/js/jquery-1.12.4.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/layui/layui.js"></script>
    <script type="text/javascript">
        //tree
        $(function(){
            $.ajax({
                url:"${pageContext.request.contextPath}/department/showAll",
                success:function(data){
                    console.log(data)
                    layui.use(['tree','element','table'], function(){
                        var table = layui.table;
                        var tree = layui.tree;
                        //渲染
                        var inst1 = tree.render({
                            elem: '#myTree'  //绑定元素
                            ,data:data
                            ,click:function(obj){
                                //console.log(obj.data)
                                //在tabs里面添加一个选项卡
                                var element = layui.element;
                                if($("li[lay-id='"+obj.data.id+"']").length==0){
                                    element.tabAdd('myTab', {
                                        title: obj.data.title
                                        ,content: "<iframe id='"+obj.data.id+"' src='${pageContext.request.contextPath}/triage.jsp?id="+obj.data.id+"' height='100%' width='100%'></iframe>" //支持传入html
                                        ,id: obj.data.id
                                    });
                                }
                                element.tabChange("myTab",obj.data.id)
                                $("#"+obj.data.id).prop("src","${pageContext.request.contextPath}/triage.jsp?id="+obj.data.id+"&date="+new Date());
                            }
                        });
                    });
                }
            })
        });


        function showkeshi() {
            layui.use('element', function(){
                var element = layui.element;
                if ($("li[lay-id='科室展示']").length==0) {
                    //console.log(1);
                    element.tabAdd('myTab', {
                        title: '科室展示'
                        ,content: '<iframe src="${pageContext.request.contextPath}/dept.jsp" height="100%" width="100%"></iframe>' //支持传入html
                        ,id: '科室展示'
                    });
                }
                element.tabChange("myTab",'科室展示')
            });
        }
        function showhuanzhe() {
            layui.use('element', function(){
                var element = layui.element;
                if ($("li[lay-id='患者展示']").length==0) {
                    //console.log(1);
                    element.tabAdd('myTab', {
                        title: '患者展示'
                        ,content: '<iframe src="${pageContext.request.contextPath}/patient.jsp" height="100%" width="100%"></iframe>' //支持传入html
                        ,id: '患者展示'
                    });
                }
                element.tabChange("myTab",'患者展示')
            });
        }
    </script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">layui 后台布局</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <%--<ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item"><a href="">控制台</a></li>
            <li class="layui-nav-item"><a href="">商品管理</a></li>
            <li class="layui-nav-item"><a href="">用户</a></li>
            <li class="layui-nav-item">
                <a href="javascript:;">其它系统</a>
                <dl class="layui-nav-child">
                    <dd><a href="">邮件管理</a></dd>
                    <dd><a href="">消息管理</a></dd>
                    <dd><a href="">授权管理</a></dd>
                </dl>
            </li>
        </ul>--%>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    贤心
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">科室管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="keshi" onclick="showkeshi()">科室展示</a></dd>
                        <%--<dd><a href="javascript:;">列表二</a></dd>
                        <dd><a href="javascript:;">列表三</a></dd>
                        <dd><a href="">超链接</a></dd>--%>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">患者管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="huanzhe" onclick="showhuanzhe()">患者展示</a></dd>
                        <%--<dd><a href="javascript:;">列表二</a></dd>
                        <dd><a href="">超链接</a></dd>--%>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">分诊管理</a>
                    <dl class="layui-nav-child">
                        <div id="myTree"></div>
                        <%--<dd><a href="javascript:;">患者展示</a></dd>--%>
                        <%--<dd><a href="javascript:;">列表二</a></dd>
                        <dd><a href="">超链接</a></dd>--%>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="">其他</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div lay-filter="myTab" class="layui-tab layui-tab-brief layui-tab-card" lay-allowClose="true">
            <ul class="layui-tab-title">
                <li class="layui-this">欢迎页</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">欢迎${sessionScope.user.username}登陆</div>
            </div>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域
    </div>
</div>

</body>
<body>

</body>
</html>
